package com.chixing.fourteen.service.impl;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradePagePayRequest;
import com.chixing.fourteen.Utils.DateUtils;
import com.chixing.fourteen.pojo.Meter;
import com.chixing.fourteen.repository.MeterRepository;
import com.chixing.fourteen.service.MeterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.Random;

/**
 * @author Y2014188432
 */
@Service
public class MeterServiceImpl implements MeterService {

    @Autowired
    private MeterRepository meterRepository;

    @Override
    /**
     * 生成流水
     */
    public int createMeter(int customerOrderId, int customerId, double price, String meterType) {
        Meter meter = new Meter();
        meter.setCustomerId(customerId);
        meter.setCustomerOrderId(customerOrderId);
        meter.setMeterNum(DateUtils.toString(new Date()));
        meter.setMeterPrice(price);
        meter.setMeterTime(new Date());
        meter.setMeterType(meterType);
        return meterRepository.insert(meter);
    }


}
